import 'package:extended_image/extended_image.dart';
///
/// [Author] Alex (https://github.com/AlexV525)
/// [Date] 2019-11-23 18:15
///
import 'package:flutter/material.dart';
import 'package:flutterlib/common/datacenter/user_center.dart';
import 'package:flutterlib/common/utils/utils.dart';
import 'package:flutterlib/common/constants/constants.dart';


class UserAvatar extends StatelessWidget {
  const UserAvatar({
    Key key,
    this.uid,
    this.size = 48.0,
    this.timestamp,
    this.radius,
    this.canJump = true,
  })  : assert(radius == null || (radius != null && radius > 0.0)),
        super(key: key);

  final double size;
  final int uid;
  final int timestamp;
  final double radius;
  final bool canJump;

  @override
  Widget build(BuildContext context) {
    final int _uid = uid ?? currentUserId;
    return SizedBox.fromSize(
      size: Size.square(size.w),
      child: GestureDetector(
        child: ClipRRect(
          borderRadius: radius != null
              ? BorderRadius.circular(radius.w)
              : maxBorderRadius,
          child: FadeInImage(
            fadeInDuration: 150.milliseconds,
            placeholder: const AssetImage(R.DEFAULT_USER_ICON),
            image: ExtendedNetworkImageProvider(
              '' + _uid.toString(),
              cache: true,
              retries: 1,
            ),
          ),
        ),
        onTap: null,
      ),
    );
  }
}
